﻿using Kevin.Comm.Strings;
using Kevin.Comm.Web;
using Kevin.Shop.Business.SalesManagement.Components.Order;
using WeixinPay.Business;

namespace WeixinPay.Models
{


    public class Package
    {
        public Package(OrderBasicInfo order)
        {
            this.BankType = "WX";
            this.FeeType = "1";
            this.InputCharset = "GBK";
            this.SpbillCreateIp = "127.0.0.1";
            this.Body = order.OrderNumber;
            this.NotifyUrl = Config.NotifyUrl;
            this.OutTradeNo = order.OrderNumber;
            this.Partner = Config.PartnerId;
            this.PartnerKey = Config.PartnerKey;
            this.TotalFee = (order.OrderPayAmount * 100M).ToString("0");
        }

        public string GetPackageString()
        {
            string str3 = StringFunction.NoneEncrypt(string.Format(string.Format("bank_type={0}&body={1}&fee_type={2}&input_charset={3}&notify_url={4}&out_trade_no={5}&partner={6}&spbill_create_ip={7}&total_fee={8}", new object[] { this.BankType, this.Body, this.FeeType, this.InputCharset, this.NotifyUrl, this.OutTradeNo, this.Partner, this.SpbillCreateIp, this.TotalFee }) + "&key={0}", this.PartnerKey), 1).ToUpper();
            this.BankType = WebHelper.UrlEncode(this.BankType);
            this.Body = WebHelper.UrlEncode(this.Body);
            this.FeeType = WebHelper.UrlEncode(this.FeeType);
            this.InputCharset = WebHelper.UrlEncode(this.InputCharset);
            this.NotifyUrl = WebHelper.UrlEncode(this.NotifyUrl);
            this.OutTradeNo = WebHelper.UrlEncode(this.OutTradeNo);
            this.Partner = WebHelper.UrlEncode(this.Partner);
            this.SpbillCreateIp = WebHelper.UrlEncode(this.SpbillCreateIp);
            this.TotalFee = WebHelper.UrlEncode(this.TotalFee);
            string str4 = string.Format(string.Format("bank_type={0}&body={1}&fee_type={2}&input_charset={3}&notify_url={4}&out_trade_no={5}&partner={6}&spbill_create_ip={7}&total_fee={8}", new object[] { this.BankType, this.Body, this.FeeType, this.InputCharset, this.NotifyUrl, this.OutTradeNo, this.Partner, this.SpbillCreateIp, this.TotalFee }) + "&sign={0}", str3);
            this.OldPackageString = str4;
            return str4;
        }

        public string BankType { get; set; }

        public string Body { get; set; }

        public string FeeType { get; set; }

        public string InputCharset { get; set; }

        public string NotifyUrl { get; set; }

        public string OldPackageString { get; set; }

        public string OutTradeNo { get; set; }

        public string Partner { get; set; }

        public string PartnerKey { get; set; }

        public string SpbillCreateIp { get; set; }

        public string TotalFee { get; set; }
    }
}

